<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href=" __PUBLIC__/Admin/css/pintuer.css">
<link rel="stylesheet" href=" __PUBLIC__/Admin/css/admin.css">
<link rel="stylesheet" href="__PUBLIC__/editor/css/editormd.min.css" />
<script src="__PUBLIC__/Admin/js/jquery.js"></script>
<script src="__PUBLIC__/Admin/js/pintuer.js"></script>
<script src="__PUBLIC__/js/jquery-2.0.2.js"></script>
<script src="__PUBLIC__/Admin/js/upload.js"></script>
<style>
		.nylDate{
			width: 147px;
			height: 43px;
			margin-left: 25px;
			border: solid 1px #ddd;
		}
		input[type=date]::-webkit-inner-spin-button { visibility: hidden; } 
		::-webkit-datetime-edit { padding: 1px; background: url(../selection.gif); } 
		/*::-webkit-datetime-edit-fields-wrapper { background-color: #eee; }*/ 
		::-webkit-datetime-edit-text { color: #4D90FE; padding: 0 .3em; } 
		/*::-webkit-datetime-edit-year-field { color: purple; } 
		::-webkit-datetime-edit-month-field { color: blue; } 
		::-webkit-datetime-edit-day-field { color: green; } */
		::-webkit-inner-spin-button { visibility: hidden; } 
		::-webkit-calendar-picker-indicator { 
			border: 1px solid #ccc; 
			border-radius: 2px; 
			box-shadow: inset 0 1px #fff, 0 1px #eee; 
			/*background-color: #eee;*/ 
			background-image: -webkit-linear-gradient(top, #f0f0f0, #e6e6e6); 
			color: #666; 
		}
</style>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加文章</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" >  
      <div class="form-group">
        <div class="label">
          <label>文章标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="title" data-validate="required:请输入标题" />
          <div class="tips"></div>
          <div class="label">
            <label>文章分类：</label>
          </div>
          <select name="cid" class="input w50">
            <option value="0">请选择分类</option>
            <foreach name="cats" item="c" >
                <option value="{$c['cid']}" <if condition="$c[cid] eq $cid">selected="selected"</if>>{$c['cname']}</option>
            </foreach>
          </select>
            <div class="label">
            <label>日期：</label>
          </div>
          <input type="date" class="nylDate" id="mydate" name="ymd" value="2018/06/06"/>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
            <label>文章内容片段：</label>
        </div>
        <div class="field">
          <textarea  name="content" class="txt" data-validate="required:*请输入文章内容"></textarea>
          <div class="tips"></div>
        </div>
      </div>
        <!--片段一-->
      <div class="module">
      <div class="form-group">
        <div class="label">
            <label>文章封面：</label>
        </div>
        <div class="field">
          <!-- <div class="input w50" data-validate="required:请选择图片">选择图片</div> -->
          <div class="input  field  upload" id="upload">
            <img id="show_img1" src="__PUBLIC__/Admin/images/default.png" alt="">
            <input type="file" id="pic1" class="pic"  val=""/>
            <input type="hidden" name="pic1" value="1">
          </div>
            <eq name="cid" value="5">
                <input type="text" style="width:85%"class="input w100" value="" name="video_link" data-validate="required:*请上传图片并添加批注" placeholder="*请输入视频地址" />
            </eq>
          <input type="text" style="width:85%"class="input w100" value="" name="discrip1" data-validate="required:*请上传图片并添加批注" placeholder="*请输入图片批注" />
          <div class="tips"></div>
        </div>
      </div>
	      <div class="form-group">
	        <div class="label">
	          <label>文章内容片段：</label>
	        </div>
	        <div class="field">
	          <textarea  name="content1" class="txt"></textarea>
	          <div class="tips"></div>
	        </div>
	      </div>
      </div>
        <!--片段一-->
          <!--片段二-->
        <div class="module">
	      <div class="form-group">
	        <div class="label">
                <label>文章图片：</label>
	        </div>
	        <div class="field">
	          <!-- <div class="input w50" data-validate="required:请选择图片">选择图片</div> -->
	          <div class="input  field  upload" id="upload">
	            <img id="show_img2" src="__PUBLIC__/Admin/images/default.png" alt="">
	            <input type="file" id="pic2" class="pic" val=""/>
	            <input type="hidden" name="pic2" value="2">
	          </div>
	          <input type="text" style="width:85%"class="input w100" value=""  name="discrip2" placeholder="*请输入图片批注" />
	          <div class="tips"></div>
	        </div>
	      </div>
        <div class="form-group">
            <div class="label">
              <label>文章内容片段：</label>
            </div>
            <div class="field">
              <textarea  name="content2" class="txt" data-validate="required:*请输入文章内容"></textarea>
              <div class="tips"></div>
            </div>
        </div>
      </div>
      <!--片段二-->
      <!--片段三-->
        <div class="module">
      	<div class="form-group">
	        <div class="label">
	          <label>文章图片：</label>
	        </div>
	        <div class="field">
	          <!-- <div class="input w50" data-validate="required:请选择图片">选择图片</div> -->
	          <div class="input  field  upload" id="upload">
	            <img id="show_img3" src="__PUBLIC__/Admin/images/default.png" alt="">
	            <input type="file" id="pic3" class="pic" val=""/>
	            <input type="hidden" name="pic3" value="1">
	          </div>
	          <input type="text" style="width:85%"class="input w100" value="" name="discrip3" placeholder="*请输入图片批注" />
	          <div class="tips"></div>
	        </div>
      	</div>
      <div class="form-group">
        <div class="label">
          <label>文章内容片段：</label>
        </div>
        <div class="field">
          <textarea name="content3" class="txt" ></textarea>
          <div class="tips"></div>
        </div>
      </div>
      </div>
      <!--片段三-->
     <div id="append"></div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o"  type="submit"> 提交</button>
          <button class="button bg-main icon-check-square-o"  id="add_module" type="button"> 增加模块</button>
        </div>
      </div>
    </form>
  </div>
</div>
<script>
        $('#add_module').click(function() {
            var num = $(".module").length+1;
            if(num < 7){
                $('#append').append(`
                <div class="module">
                <div class="form-group">
                    <div class="label">
                      <label>文章图片：</label>
                    </div>
                    <div class="field">
                      <div class="input  field  upload">
                        <img id='show_img${num}' src="__PUBLIC__/Admin/images/default.png" alt="">
                        <input type="file" id="pic${num}" class="pic" val=""  onchange="upload(this)"/>
                        <input type="hidden" name="pic${num}" value="1">
                              </div>
                              <input type="text" style="width:85%"class="input w100" value="" name="discrip${num}" placeholder="*请输入图片批注" />
                              <div class="tips"></div>
                            </div>
                        </div>
                      <div class="form-group">
                        <div class="label">
                          <label>文章内容片段：</label>
                        </div>
                        <div class="field">
                          <textarea name="content${num}" class="txt" ></textarea>
                          <div class="tips"></div>
                        </div>
                      </div>
                      </div>
                      </div>`)
            }else{
                alert("最多6个模块")
            }
            }

        );
        $('.pic').change(function(){
                upload(this)
        });
        var upload = function(This){
            var picid = $(This).attr("id");
            var show_img = 'show_img'+picid.slice(3);
            PUB.upload.checkImg(picid,show_img);
            PUB.upload.img_upload(picid,"{:U('Admin/upload/upload')}");
        }
   
        var now = new Date();
		//格式化日，如果小于9，前面补0
		var day = ("0" + now.getDate()).slice(-2);
		//格式化月，如果小于9，前面补0
		var month = ("0" + (now.getMonth() + 1)).slice(-2);
		//拼装完整日期格式
		var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
		//完成赋值
		$('.nylDate').val(today);

			
</script>
</body>
</html>

